package com.wkg.lotterysystem.dao.mapper;

import com.wkg.lotterysystem.dao.dataobject.ActivityDo;
import com.wkg.lotterysystem.service.enums.ActivityStatusEnum;
import lombok.Data;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ActivityMapper {

    @Insert("insert into activity (activity_name,description,status) " +
            " values (#{activityName},#{description},#{status})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    int insert(ActivityDo activityDo);

    @Select("select count(1) from  activity")
    int count();

    @Select("select * from activity order by id desc limit #{offset},#{pageSize}")
    List<ActivityDo> selectActivityList(@Param("offset") Integer offset,
                                        @Param(("pageSize")) Integer pageSize);

    @Select("select * from activity where id = #{id}")
    ActivityDo selectById(@Param("id") Integer id);

    @Update("update activity set status=#{status} where id=#{id}")
    void updateStatus(@Param("id") Integer id, @Param("status") String status);
}
